package base

import system.Department
import system.StaffMember

/*项目 维度*/

class Project {
/*项目名称*/
    String name
/*项目编号*/
    String code
/*是否启用*/
    Boolean enabled=true
/*项 目 年*/
    Integer year
/*项目总预算*/
    BigDecimal budget
/*归属部门*/
    Department department
/*项目负责人-- 归属部门下面的用户*/
    StaffMember owner
/*项目经理 -- 归属部门下面的用户*/
    StaffMember manager
    /*核算名称*/
    String hsName
    /*核算编码*/
    String hsCode
    /*备注*/
    String memo

    /*创建时间*/
    Date dateCreated
    /*最后更新的时间*/
    Date lastUpdated
    static constraints = {
        enabled nullable: true
        year nullable: true
        budget nullable: true
        department nullable: true
        owner nullable: true
        manager nullable: true
        hsName nullable: true
        hsCode nullable: true
        memo nullable: true,maxSize: 1000
    }

    transient utilsService
    def buildDomain() {
        def b = [:] + this.properties
        def param = [allowformat: true, allowprecision: false]
        b = utilsService.truncProp(this, b, param) { amap ->
            amap << ['id': this.id]

        }
        b
    }

    def buildDomainList(list) {
        def rds = []
        list.each {
            def b = [:] + it.properties
            def param = [allowformat: true, allowprecision: false]
            b = utilsService.truncProp(it, b, param) { amap ->
                amap << ['id': it.id]
            }
            rds << b
        }
        return rds
    }
}
